﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MyProfile.aspx.cs" Inherits="carportal.MyProfile" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style3
        {
            width: 129px;
        }
        .style4
        {}
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:bestgifts4usConnectionString %>" 
        DeleteCommand="DELETE FROM [carportal_users] WHERE [user_id] = @user_id" 
        InsertCommand="INSERT INTO [carportal_users] ([user_phone], [user_address]) VALUES (@user_phone, @user_address)" 
        SelectCommand="SELECT [user_phone], [user_address], [image_address] as image_addr, [user_id] FROM [carportal_users] WHERE ([user_id] = @user_id)" 
        
        
        
        UpdateCommand="UPDATE carportal_users SET user_phone = @user_phone, user_address = @user_address, image_address = @image_address WHERE (user_id = @user_id)">
        <DeleteParameters>
            <asp:Parameter Name="user_id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="user_phone" Type="String" />
            <asp:Parameter Name="user_address" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:SessionParameter Name="user_id" SessionField="UserID" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="user_phone" Type="String" />
            <asp:Parameter Name="user_address" Type="String" />
            <asp:Parameter Name="user_id" Type="Int32" />
            <asp:Parameter Name="image_address"  Type="String"  />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:FormView ID="FormView1" runat="server" CssClass="style4" 
        DataKeyNames="user_id" DataSourceID="SqlDataSource1" DefaultMode="Edit" 
        Width="423px" onitemupdated="FormView1_ItemUpdated" 
        onitemupdating="FormView1_ItemUpdating">
        <EditItemTemplate>
            <table class="style1">
                <tr>
                    <td align="right" class="style3">
                        Phone Number:
                    </td>
                    <td>
                        <asp:TextBox ID="user_phoneTextBox" runat="server" 
                            Text='<%# Bind("user_phone") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right" class="style3">
                        Your Address:
                    </td>
                    <td>
                        <asp:TextBox ID="user_addressTextBox" runat="server" 
                            Text='<%# Bind("user_address") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right" class="style3">
                        Your Current Photo:</td>
                    <td>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("image_addr") %>' />
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("image_addr") %>' 
                            Visible="False"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="style3">
                        Upload New Photo:</td>
                    <td>
                        <asp:FileUpload ID="FileUpload1" runat="server" />
                    </td>
                </tr>
            </table>
            <asp:Label ID="user_idLabel1" runat="server" Text='<%# Eval("user_id") %>' 
                Visible="False" />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update"   Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            user_phone:
            <asp:TextBox ID="user_phoneTextBox" runat="server" 
                Text='<%# Bind("user_phone") %>' />
            <br />
            user_address:
            <asp:TextBox ID="user_addressTextBox" runat="server" 
                Text='<%# Bind("user_address") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            user_phone:
            <asp:Label ID="user_phoneLabel" runat="server" 
                Text='<%# Bind("user_phone") %>' />
            <br />
            user_address:
            <asp:Label ID="user_addressLabel" runat="server" 
                Text='<%# Bind("user_address") %>' />
            <br />
            user_id:
            <asp:Label ID="user_idLabel" runat="server" Text='<%# Eval("user_id") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />
            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
        </ItemTemplate>
    </asp:FormView>
</asp:Content>
